<template>
  <view>
    <u-navbar
      :title="title"
      :background="background"
      :back-icon-color="backIconColor"
      :title-color="titleColor"
      :title-bold="true"
      :border-bottom="false"
      title-width="300"
    >
      <view
        class="nav-right"
        slot="right"
        v-if="mode == 'user'"
        @click="toTabPage('user')"
        >我的</view
      >
      <view
        class="nav-right"
        slot="right"
        v-else-if="mode == 'setting'"
        @click="toPage('setting/setting')"
        >设置</view
      >
    </u-navbar>
  </view>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: "",
    },
    mode: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      background: {
        backgroundColor: "rgb(51, 204, 0)",
      },
      backIconColor: "#fff",
      titleColor: "#fff",
    };
  },
  methods: {
    toTabPage(page) {
      uni.switchTab({
        url: "/pages/" + page,
      });
    },
    toPage(page) {
      uni.navigateTo({
        url: "/pages/" + page,
      });
    },
  },
};
</script>

<style scoped>
.nav-right {
  margin-right: 20rpx;
  color: #fff;
}
</style>
